<template>
  <div class="app-container">
    <el-button type="primary" plain>出库单信息</el-button>
    <el-form :model="form" ref="form" size="small" inline label-width="108px" style="margin-top: 40px">
      <el-form-item label="出库单号："  ><el-input v-model="orderList.orderNo" readonly /></el-form-item>
      <el-form-item label="公司："   ><el-input v-model="orderList.companyName" readonly /></el-form-item>
      <el-form-item label="门店："   ><el-input v-model="orderList.shopName" readonly /></el-form-item></br>
      <el-form-item label="操作人："   ><el-input v-model="orderList.user" readonly /></el-form-item>
      <el-form-item label="出库类型："   ><el-input v-model="dict.type.sys_stock_type[orderList.type-1].label" readonly /></el-form-item>
      <el-form-item label="状态："   ><el-input v-model="dict.type.sys_list_status[orderList.status].label" readonly /></el-form-item></br>
      <el-form-item label="创建时间："   ><el-input v-model="orderList.ctime" readonly /></el-form-item>
      <el-form-item label="审核时间："   ><el-input v-model="orderList.reviewTime" readonly /></el-form-item>
      <el-form-item label="备注："   ><el-input v-model="orderList.remark" readonly /></el-form-item>

    </el-form>

    <el-button type="primary" icon="el-icon-plus" size="mini" @click="open = true">清单商品</el-button>
    <el-table :data="goodsSelect" style="margin-top: 20px">
      <!-- 隐藏id列 -->
      <el-table-column prop="goodsName" label="商品名称" ></el-table-column>
      <el-table-column prop="goodsNum" isedit label="出库数量" ></el-table-column>
      <el-table-column prop="goodsUnit"  label="单位" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_goods_unit" :value="scope.row.goodsUnit"/>
        </template>
      </el-table-column>
      <el-table-column prop="remark" label="备注" ></el-table-column>

    </el-table>

    <el-form :model="form" ref="form" size="small" label-width="68px" style="bottom: 0;position: fixed;width: 100%;background-color: #fff;padding: 10px;">

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="submitForm">确定</el-button>
      </el-form-item>
    </el-form>



  </div>
</template>

<script>
import {getListGoods,updateOrderGoods,getList} from "@/api/system/outboundList"
import {listCompanyGoods} from "@/api/system/companyGoods"
import {getOrderGoodsDetail, getOrderlist} from "@/api/system/orderlist";

export default {
  name: "obListInfo",
  dicts: ['sys_list_status', 'sys_stock_type','sys_goods_unit'],
  data() {
    return {
      //出库单ID
      listid:"",
      //出库单信息
      orderList:[],
      //已选择商品列表
      goodsSelect:[],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,

      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 品类数量时间范围
      daterangeCtime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ctime: null,
        acceptTime: null,
        arriveTime: null,
        status: null,
        orderNo: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    }
  },
  created() {
    this.listid = this.$route.query.id
    console.log("编辑ID",this.listid)
    this.getList()
    this.getOrderGoods()
  },
  methods: {
    // 获取出库单信息
    getList() {
      this.loading = true
      getList(this.listid).then(response => {
        this.loading = false
        this.orderList = response.data
      })
    },
    // 获取公司商品

    //获取选中商品
    getOrderGoods(){
      getListGoods(this.listid).then(response => {
        this.goodsSelect = response.rows
        console.log("选中商品：",this.goodsSelect)
      })

    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        companyId: null,
        shopId: null,
        ctime: null,
        acceptTime: null,
        arriveTime: null,
        status: null,
        supplyId: null,
        orderNo: null,
        userId: null,
        price: null,
        remark: null,
        kind: null
      }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeCtime = []
      this.resetForm("queryForm")
      this.handleQuery()
    },
    /** 提交按钮 */

    /** 提交按钮 */
    submitForm() {
      //关闭页面
      this.$store.dispatch("tagsView/delView", this.$route)
      this.$router.go(-1)
    },
  }
}
</script>
